<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Android.mk﻿﻿语法规范 - 咕唧咕唧的专栏 - 博客频道 - CSDN.NET</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Android.mk是Android提供的一种makefile文件，用来指定诸如编译生成so库名、引用的头文件目录、需要编译的.c/.cpp文件和.a静态库文件等。要掌握jni，就必须熟练掌握Android.mk的语法规范。一、Android.mk文件的用途一个android子项目中会存在一个或多个Android.mk文件1、单一的Android.mk文件直接参考NDK的sampl" />
<script src="http://static.blog.csdn.net/scripts/jquery.js" type="text/javascript"></script>
<script type="text/javascript" src="http://static.blog.csdn.net/scripts/ad.js?v=1.1"></script>
<link rel="Stylesheet" type="text/css" href="http://static.blog.csdn.net/skin/dark1/css/style.css?v=1.1" />
<link id="RSSLink" title="RSS" type="application/rss+xml" rel="alternate" href="/liukun321/rss/list" />
<link rel="shortcut icon" href="/favicon.ico" />
<link type="text/css" rel="stylesheet" href="http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/blue_black.css" />
</head>
<body>
<script src="http://csdnimg.cn/pubnav/js/pub_topnav_2011.js"type="text/javascript"></script>

<div id="container">
<div id="header">
    <div class="header">
        <div id="blog_title">
            <h1><a href="/liukun321">咕唧咕唧的专栏</a></h1>
            <h2>不在乎我拥有多少，而是我奉献多少!</h2>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
    </div>
</div>
<div id="navigator">
    <div class="navigator_bg"></div>
    <div class="navigator">
        <ul>
            <li id="btnContents"><a href="/liukun321?viewmode=contents"><span><img src="http://static.blog.csdn.net/images/ico_list.gif">目录视图</span></a></li>
            <li id="btnView"><a href="/liukun321?viewmode=list"><span><img src="http://static.blog.csdn.net/images/ico_summary.gif">摘要视图</span></a></li>
            <li id="btnRss"><a href="/liukun321/rss/list"><span><img src="http://static.blog.csdn.net/images/ico_rss.gif">订阅</span></a></li>
</ul>
    </div>
</div>
<script type="text/javascript">
    var username = "liukun321";
    var _blogger = username;
    var blog_address = "http://blog.csdn.net/liukun321";
    var static_host = "http://static.blog.csdn.net";
    var currentUserName = "hutianxi1129";
</script>

<div id="body">
<div id="main">
<div class="main">
<div class="notice"> 

<a href="https://code.csdn.net/blog/12" target="_blank">
<font color=red>公告：博客新增直接引用代码功能</font></a>



&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<a href="http://www.csdn.net/article/2013-07-09/2816160" target="_blank"><font color=blue>专访赵霏：应把握机会 HTML5游戏开发已臻成熟 
</font></a>

&nbsp;&nbsp;&nbsp;&nbsp;

<a href="http://blog.csdn.net/csdnproduct/article/details/9226265
"target="_blank">
<font color=red>CSDN博客频道自定义摘要、图片水印、热门标签等功能上线啦 


 </font></a>

&nbsp;&nbsp;&nbsp;&nbsp;

<a href="http://blog.csdn.net/blogdevteam/article/details/9136613"target="_blank">
<font color=red>CSDN博客第二期云计算最佳博主评选

 </font></a>


&nbsp;&nbsp;&nbsp;&nbsp;

<a href=""target="_blank">
<font color=blue>
 </font></a>




</div>
<div id="article_details" class="details">
    <div class="article_title">
    <span class="ico ico_type_Repost"></span>
    <h3>
        <span class="link_title"><a href="/liukun321/article/details/8848417">
        Android.mk﻿﻿语法规范
        </a></span>
    </h3>
</div>

        
    <div class="article_manage">
        <span class="link_categories">
        分类：
            <a href="/liukun321/article/category/1400890">Android 编译</a> 
        </span>
    <span class="link_postdate">2013-04-25 10:42</span>
    <span class="link_view" title="阅读次数">355人阅读</span>
    <span class="link_comments" title="评论次数"><a href="#comments">评论</a>(1)</span>
    <span class="link_collect"><a href="javascript:void(0);" onclick="javascript:collectArticle('Android.mk﻿﻿语法规范','8848417');return false;" title="收藏">收藏</a></span>
    <span class="link_report"><a href="#report"  onclick="javascript:report(8848417,2);return false;" title="举报">举报</a></span>
    
</div>


    
<div id="article_content" class="article_content">

<p>Android.mk是Android提供的一种makefile文件，用来指定诸如编译生成so库名、引用的头文件目录、需要编译的.c/.cpp文件和.a静态库文件等。要掌握jni，就必须熟练掌握Android.mk的语法规范。</p>
<p><strong>一、Android.mk文件的用途<br>
</strong>一个android子项目中会存在一个或多个Android.mk文件<br>
1、单一的Android.mk文件<br>
直接参考NDK的sample目录下的hello-jni项目，在这个项目中只有一个Android.mk文件<br>
2、多个Android.mk文件<br>
如果需要编译的模块比较多，我们可能会将对应的模块放置在相应的目录中，<br>
这样，我们可以在每个目录中定义对应的Android.mk文件（类&#20284;于上面的写法），<br>
最后，在根目录放置一个Android.mk文件，内容如下：<br>
<span style="color:#ff0000">include $(call all-subdir-makefiles)<br>
只需要这一行就可以了，它的作用就是包含所有子目录中的Android.mk文件<br>
</span>3、多个模块共用一个Android.mk<br>
这个文件允许你将源文件组织成模块，这个模块中含有：<br>
&nbsp;<wbr> -静态库(.a文件)<br>
&nbsp;<wbr> -动态库(.so文件)<br>
只有共享库才能被安装/复制到您的应用软件（APK）包中<br>
<span style="color:#ff0000">include $(BUILD_STATIC_LIBRARY)，编译出的是静态库<br>
include $(BUILD_SHARED_LIBRARY)，编译出的是动态库</span></p>
<p>&nbsp;<wbr></p>
<p><strong>二、自定义变量</strong><br>
&nbsp;<wbr>以下是在 Android.mk中依赖或定义的变量列表，可以定义其他变量为自己使用，但是NDK编译系统保留下列变量名：<br>
&nbsp;<wbr>-以 LOCAL_开头的名字（例如 LOCAL_MODULE）<br>
&nbsp;<wbr>-以 PRIVATE_, NDK_ 或 APP_开头的名字（内部使用）<br>
&nbsp;<wbr>-小写名字（内部使用，例如‘my-dir’）<br>
&nbsp;<wbr> 如果为了方便在 Android.mk 中定义自己的变量，建议使用 MY_前缀，一个小例子：<br>
MY_SOURCES := foo.c<br>
ifneq ($(MY_CONFIG_BAR),)<br>
&nbsp;<wbr>MY_SOURCES &#43;= bar.c<br>
endif<br>
LOCAL_SRC_FILES &#43;= $(MY_SOURCES)<br>
注意：‘:=’是赋&#20540;的意思；'&#43;='是追加的意思；‘$’表示引用某变量的&#20540;。</p>
<p>&nbsp;<wbr></p>
<p><strong>三、GNU Make系统变量</strong><br>
&nbsp;<wbr> 这些 GNU Make变量在你的 Android.mk 文件解析之前，就由编译系统定义好了。注意在某些情况下，NDK可能分析 Android.mk 几次，每一次某些变量的定义会有不同。<br>
&nbsp;<wbr> （1）CLEAR_VARS:&nbsp;<wbr> 指向一个编译脚本，几乎所有未定义的 LOCAL_XXX 变量都在&quot;Module-description&quot;节中列出。必须在开始一个新模块之前包含这个脚本：<span style="color:#ff0000">include$(CLEAR_VARS)，用于重置除LOCAL_PATH变量外的，所有LOCAL_XXX系列变量。<br>
</span>&nbsp;<wbr> （2）<span style="color:#ff0000">BUILD_SHARED_LIBRARY:</span>&nbsp;<wbr> 指向编译脚本，根据所有的在 LOCAL_XXX 变量把列出的源代码文件编译成一个共享库。<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span style="color:#ff0000"> 注意，必须至少在包含这个文件之前定义 LOCAL_MODULE 和 LOCAL_SRC_FILES。<br>
</span>&nbsp;<wbr> （3）BUILD_STATIC_LIBRARY:&nbsp;<wbr> 一个 BUILD_SHARED_LIBRARY 变量用于编译一个静态库。<span style="color:#ff0000">静态库不会复制到的APK包中，但是能够用于编译共享库。<br>
</span>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span style="color:#ff0000"> 示例：include $(BUILD_STATIC_LIBRARY)<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> 注意，这将会生成一个名为 lib$(LOCAL_MODULE).a 的文件<br>
</span>&nbsp;<wbr> （4）TARGET_ARCH: 目标 CPU平台的名字<br>
&nbsp;<wbr> （5）TARGET_PLATFORM: Android.mk 解析的时候，目标 Android 平台的名字.详情可考/development/ndk/docs/stable- apis.txt.<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> android-3 -&gt; Official Android 1.5 system images<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> android-4 -&gt; Official Android 1.6 system images<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> android-5 -&gt; Official Android 2.0 system images<br>
&nbsp;<wbr> （6）<span style="color:#ff0000">TARGET_ARCH_ABI:</span>&nbsp;<wbr> 暂时只支持两个 value，<span style="color:#ff0000">armeabi 和 armeabi-v7a。。<br>
</span>&nbsp;<wbr> （7）TARGET_ABI: 目标平台和 ABI 的组合，</p>
<p>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><br>
<strong>四、模块描述变量<br>
</strong>&nbsp;<wbr><span style="color:#ff0000"> 下面的变量用于向编译系统描述你的模块。应该定义在'include&nbsp;<wbr> $(CLEAR_VARS)'和'include $(BUILD_XXXXX)'之间。$(CLEAR_VARS)是一个脚本，清除所有这些变量。<br>
</span>&nbsp;<wbr> （1）<span style="color:#ff0000">LOCAL_PATH:&nbsp;<wbr> 这个变量用于给出当前文件的路径。<br>
</span>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> 必须在 Android.mk 的开头定义，可以这样使用：LOCAL_PATH := $(call my-dir)<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> 如当前目录下有个文件夹名称 src，则可以这样写 $(call src)，那么就会得到 src 目录的完整路径<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> 这个变量不会被$(CLEAR_VARS)清除，因此每个 Android.mk 只需要定义一次(即使在一个文件中定义了几个模块的情况下)。<br>
&nbsp;<wbr> （2）<span style="color:#ff0000">LOCAL_MODULE: 这是模块的名字，它必须是唯一的，而且不能包含空&#26684;</span>。<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> <span style="color:#ff0000">必须在包含任一的$(BUILD_XXXX)脚本之前定义它。</span>模块的名字决定了生成文件的名字。<br>
&nbsp;<wbr> （3）<span style="color:#ff0000">LOCAL_SRC_FILES</span>:&nbsp;<wbr> <span style="color:#ff0000">
这是要编译的源代码文件列表。<br>
</span>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> 只要列出要传递给编译器的文件，因为编译系统自动计算依赖。<span style="color:#ff0000">注意源代码文件名称都是相对于 LOCAL_PATH的</span>，你可以使用路径部分，例如：<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> LOCAL_SRC_FILES := foo.c toto/bar.c\<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> Hello.c<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span style="color:#ff0000"> 文件之间可以用空&#26684;或Tab键进行分割,换行请用&quot;\&quot;<br>
</span>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> 如果是追加源代码文件的话，请用LOCAL_SRC_FILES &#43;=<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span style="color:#ff0000"> 注意：可以LOCAL_SRC_FILES := $(call all-subdir-java-files)这种形式来包含local_path目录下的所有java文件。<br>
</span>&nbsp;<wbr> （4）<span style="color:#ff0000">LOCAL_C_INCLUDES:&nbsp;<wbr> 可选变量，表示头文件的搜索路径。<br>
</span>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span style="color:#ff0000"> 默认的头文件的搜索路径是LOCAL_PATH目录。<br>
</span>&nbsp;<wbr> （5）<span style="background-color:#ffff33">LOCAL_STATIC_LIBRARIES: 表示该模块需要使用哪些静态库，以便在编译时进行链接。<br>
</span>&nbsp;<wbr> （6）<span style="background-color:#ffff33">LOCAL_SHARED_LIBRARIES:&nbsp;<wbr> 表示模块在运行时要依赖的共享库（动态库），在链接时就需要，以便在生成文件时嵌入其相应的信息。<br>
</span>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> 注意：它不会附加列出的模块到编译图，也就是仍然需要在Application.mk 中把它们添加到程序要求的模块中。<br>
&nbsp;<wbr> （7）LOCAL_LDLIBS:&nbsp;<wbr> 编译模块时要使用的附加的链接器选项。这对于使用‘-l’前缀传递指定库的名字是有用的。<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> 例如，<span style="color:#ff0000">LOCAL_LDLIBS := -lz表示告诉链接器生成的模块要在加载时刻链接到/system/lib/libz.so<br>
</span>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> 可查看 docs/STABLE-APIS.TXT 获取使用 NDK发行版能链接到的开放的系统库列表。<br>
&nbsp;<wbr>&nbsp;<wbr> (8)LOCAL_MODULE_PATH 和 LOCAL_UNSTRIPPED_PATH<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> 在 Android.mk 文件中， 还可以用LOCAL_MODULE_PATH 和LOCAL_UNSTRIPPED_PATH指定最后的目标安装路径.<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> 不同的文件系统路径用以下的宏进行选择：<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr><span style="color:#000000; background-color:#ffff66"> TARGET_ROOT_OUT：表示根文件系统。<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> TARGET_OUT：表示 system文件系统。<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> TARGET_OUT_DATA：表示 data文件系统。<br>
</span>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> 用法如：LOCAL_MODULE_PATH :=$(TARGET_ROOT_OUT)<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> 至于LOCAL_MODULE_PATH 和LOCAL_UNSTRIPPED_PATH的区别，暂时还不清楚。<br>
&nbsp;<wbr>&nbsp;<wbr> （9）<span style="background-color:#ffff66">LOCAL_JNI_SHARED_LIBRARIES：定义了要包含的so库文件的名字，如果程序没有采用jni，不需要<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> LOCAL_JNI_SHARED_LIBRARIES := libxxx 这样在编译的时候，NDK自动会把这个libxxx打包进apk； 放在youapk/lib/目录下</span></p>
<p>&nbsp;<wbr></p>
<p><strong>五、NDK提供的函数宏<br>
</strong>GNU Make函数宏，必须通过使用'$(call&nbsp;<wbr> )'来调用，返回&#20540;是文本化的信息。<br>
&nbsp;<wbr>&nbsp;<wbr> （1）my-dir:返回当前 Android.mk 所在的目录的路径，相对于 NDK 编译系统的顶层。这是有用的，在 Android.mk 文件的开头如此定义：<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> LOCAL_PATH := $(call my-dir)<br>
&nbsp;<wbr>&nbsp;<wbr> （2）all-subdir-makefiles: 返回一个位于当前'my-dir'路径的子目录中的所有Android.mk的列表。<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> 例如，某一子项目的目录层次如下：<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> src/foo/Android.mk<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> src/foo/lib1/Android.mk<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> src/foo/lib2/Android.mk<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> 如果 src/foo/Android.mk 包含一行：<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> include $(call all-subdir-makefiles)<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> 那么它就会自动包含 src/foo/lib1/Android.mk 和 src/foo/lib2/Android.mk。<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> 这项功能用于向编译系统提供深层次嵌套的代码目录层次。<br>
&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr>&nbsp;<wbr> 注意，在默认情况下，NDK 将会只搜索在 src/*/Android.mk 中的文件。<br>
&nbsp;<wbr>&nbsp;<wbr> （3）this-makefile:&nbsp;<wbr> 返回当前Makefile 的路径(即这个函数调用的地方)<br>
&nbsp;<wbr>&nbsp;<wbr> （4）parent-makefile:&nbsp;<wbr> 返回调用树中父 Makefile 路径。即包含当前Makefile的Makefile 路径。<br>
&nbsp;<wbr>&nbsp;<wbr> （5）grand-parent-makefile：返回调用树中父Makefile的父Makefile的路径</p>
<p>&nbsp;<wbr></p>
<p><strong>六、 Android.mk示例<br>
</strong>#编译静态库<br>
LOCAL_PATH := $(call my-dir)<br>
include $(CLEAR_VARS)<br>
LOCAL_MODULE = libhellos<br>
LOCAL_CFLAGS = $(L_CFLAGS)<br>
LOCAL_SRC_FILES = hellos.c<br>
LOCAL_C_INCLUDES = $(INCLUDES)<br>
LOCAL_SHARED_LIBRARIES := libcutils<br>
LOCAL_COPY_HEADERS_TO := libhellos<br>
LOCAL_COPY_HEADERS := hellos.h<br>
include $(BUILD_STATIC_LIBRARY)</p>
<p>#编译动态库<br>
LOCAL_PATH := $(call my-dir)<br>
include $(CLEAR_VARS)<br>
LOCAL_MODULE = libhellod<br>
LOCAL_CFLAGS = $(L_CFLAGS)<br>
LOCAL_SRC_FILES = hellod.c<br>
LOCAL_C_INCLUDES = $(INCLUDES)<br>
LOCAL_SHARED_LIBRARIES := libcutils<br>
LOCAL_COPY_HEADERS_TO := libhellod<br>
LOCAL_COPY_HEADERS := hellod.h<br>
include $(BUILD_SHARED_LIBRARY)</p>
<p>#使用静态库<br>
LOCAL_PATH := $(call my-dir)<br>
include $(CLEAR_VARS)<br>
LOCAL_MODULE := hellos<br>
LOCAL_STATIC_LIBRARIES := libhellos<br>
LOCAL_SHARED_LIBRARIES :=<br>
LOCAL_LDLIBS &#43;= -ldl<br>
LOCAL_CFLAGS := $(L_CFLAGS)<br>
LOCAL_SRC_FILES := mains.c<br>
LOCAL_C_INCLUDES := $(INCLUDES)<br>
include $(BUILD_EXECUTABLE)</p>
<p>#使用动态库<br>
LOCAL_PATH := $(call my-dir)<br>
include $(CLEAR_VARS)<br>
LOCAL_MODULE := hellod<br>
LOCAL_MODULE_TAGS := debug<br>
LOCAL_SHARED_LIBRARIES := libc libcutils libhellod<br>
LOCAL_LDLIBS &#43;= -ldl<br>
LOCAL_CFLAGS := $(L_CFLAGS)<br>
LOCAL_SRC_FILES := maind.c<br>
LOCAL_C_INCLUDES := $(INCLUDES)<br>
include $(BUILD_EXECUTABLE)</p>
<p>Android.mk给变量赋&#20540;，同时用的“:=”和“=”，他们分别代表什么意思呢？</p>
<p>“:=” 的意思是，它右边赋得&#20540;如果是变量，只能使用在这条语句之前定义好的，而不能使用本条语句之后定义的变量；</p>
<p>“=”，当它的右边赋&#20540;是变量时，这个变量的定义在本条语句之前或之后都可以；<br>
<br>
本文欢迎转载，转载请注明作者与出处</p>
<p>作者：流星</p>
<p>出处：<a href="http://blog.sina.com.cn/staratsky">http://blog.sina.com.cn/</a><a href="http://blog.sina.com.cn/staratsky">staratsky</a></p>

</div>

<div class="share_buttons" id="sharePanel"></div>
<!--192.168.100.34-->
<div class="article_next_prev">
    <li class="prev_article"><span>上一篇：</span><a href="/liukun321/article/details/8848293">Android.mk 编写规则简介</a></li>
    <li class="next_article"><span>下一篇：</span><a href="/liukun321/article/details/8849973">认识*.so里的JNI_OnLoad()函数</a></li>
</div>


    
</div>
<div id="ad_cen">
<script type="text/javascript" >BAIDU_CLB_SLOT_ID = "117306";</script>
<script type="text/javascript" src="http://cbjs.baidu.com/js/o.js"></script>
</div>
<script type="text/javascript">
    //new Ad(4, 'ad_cen');
</script>
<div id="comment_title" class="panel_head">查看评论<a name="comments"></a></div>
<div id="comment_list"></div>
<div id="comment_bar"></div>
<div id="comment_form"></div>
<div class="announce">* 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场<a name="reply"></a><a name="quote"></a></div>
<script type="text/javascript">
    var fileName = '8848417';
    var commentscount = 1;
    var islock = false
</script>
<script type="text/javascript" src="http://static.blog.csdn.net/scripts/comment.js"></script>
<div id="ad_bot"></div>
<script type="text/javascript">
    new Ad(5, 'ad_bot');
</script>
<div id="report_dialog"></div>

<div id="d-top" style="display:none;">
<a id="d-top-a" href="#" title="回到顶部">
<img src="http://static.blog.csdn.net/images/top.png" alt="TOP" /></a>
</div>
<script type="text/javascript">
    $(function(){
        var d_top=$('#d-top');
        document.onscroll=function(){
            var scrTop=(document.body.scrollTop||document.documentElement.scrollTop);
            if(scrTop>500){
                d_top.show();
            }else{
                d_top.hide();
            }
        }
        $('#d-top-a').click(function(){
            scrollTo(0,0);
            this.blur();
            return false;
        });
    });
</script>

<div class="clear"></div>
</div>
</div>

<div id="side">
<div class="side">
<div id="panel_Profile" class="panel">
<ul class="panel_head"><span>个人资料</span></ul>
<ul class="panel_body profile">
<div id="blog_userface">
    <a href="http://my.csdn.net/liukun321" target="_blank">
    <img src="http://avatar.csdn.net/A/7/A/1_liukun321.jpg" title="访问我的空间" style="max-width:90%"/>
    </a>
    <br />
    <span><a href="http://my.csdn.net/liukun321" class="user_name" target="_blank">liukun321</a></span>
</div>
<div class="interact">
<a href="javascript:void(0);" class="attent" id="span_add_follow" title="[加关注]"></a>
<a href="javascript:void(0);" class="letter" onclick="loginto(1)" title="[发私信]"></a>
</div>
<div id="blog_medal">
</div>
<ul id="blog_rank">
    <li>访问：<span>193944次</span></li>
    <li>积分：<span>3551分</span></li>
    <li>排名：<span>第1630名</span></li>
</ul>
<ul id="blog_statistics">
    <li>原创：<span>142篇</span></li>
    <li>转载：<span>102篇</span></li>
    <li>译文：<span>0篇</span></li>
    <li>评论：<span>254条</span></li>
</ul>
</ul>
</div>

<div class="panel">
<ul class="panel_body" style="padding:0;">
<script type="text/javascript" src="http://cbjs.baidu.com/js/m.js"></script> 
<script type="text/javascript"> 
BAIDU_CLB_preloadSlots("724643","117306"); 
</script>
<script type="text/javascript">BAIDU_CLB_fillSlot("724643");</script> 
</ul>
</div>
<div class="panel" id="panel_Search">
    <ul class="panel_head"><span>文章搜索</span></ul>
    <ul class="panel_body">
        <form id="frmSearch" action="http://so.csdn.net/search" class="form_search" target="_blank">
        <span><input id="inputSearch" type="text" class="blogsearch" title="请输入关键字" /></span>
        <input id="btnSubmit" type="submit" value="搜索" title="search in blog" />
        <input type="hidden" name="q" id="inputQ" />
        <input type="hidden" name="t" value="blog" />
        <a id="btnSearchBlog" target="_blank"></a>
        </form>
    </ul>
</div><div id="custom_column_2992262" class="panel">
<ul class="panel_head"><span>公告板</span></ul>
<ul class="panel_body">

由于发现原创文章，在未署名作者及出处的情况下被转载。在以后所有的原创文章开头我都会写明作者和出处。希望朋友们以后在转载本博客原创博文时注意标明文章作者及出处。欢迎大家加入LINUX讨论群 群号143898979

</ul>
</div><div id="panel_Category" class="panel">
    <ul class="panel_head"><span>博客专栏</span></ul>
    <ul class="panel_body" id="sp_column">
    <table cellpadding="0" cellspacing="0"><tr>
    <td style="padding:10px 10px 0 0;">
    <a href="http://blog.csdn.net/column/details/u-boot.html" target="_blank"><img src="http://avatar.csdn.net/blogpic/20130121223541471.jpg" style="width:75px;height:75px;" /></a>
    </td>
    <td style="padding:10px 0; vertical-align:top;">
    <a href="http://blog.csdn.net/column/details/u-boot.html" target="_blank">u-boot for tiny210</a>
    <p>文章：10篇</p>
    <span>阅读：35480</span>
    </td>
    </tr></table>
    </ul>
</div><div id="panel_Category" class="panel">
<ul class="panel_head"><span>文章分类</span></ul>
<ul class="panel_body">
<li>
<a href="http://blog.csdn.net/liukun321/article/category/1441171">liukun321原创s5pv210+XC3S400A工程板</a><span>(1)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/1501881">视频编解码（210硬件编解码）</a><span>(2)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/1400890">Android 编译</a><span>(3)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/1070782">Android Develope</a><span>(11)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/942515">IT新动态</a><span>(4)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/1518795">MultiMedia</a><span>(1)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/1060846">程序人生</a><span>(5)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/949637">linux kernel</a><span>(1)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/857082">linux 移植</a><span>(24)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/906299">linux 设备驱动</a><span>(21)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/914080">linux 应用程序编程</a><span>(8)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/914175">linux 系统使用及维护</a><span>(1)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/946303">错误杂项</a><span>(1)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/1060900">硬件</a><span>(3)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/1135247">S5pv210-u-boot</a><span>(12)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/857079">uboot移植</a><span>(18)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/700082">OS</a><span>(36)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/740381">s3c2440</a><span>(4)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/857081">文件系统</a><span>(4)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/692558">ARM语言基础</a><span>(22)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/695242">各模式下的UART</a><span>(5)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/692560">关于中断和代码搬运</a><span>(4)</span>
</li>
<li>
<a href="http://blog.csdn.net/liukun321/article/category/691641">44B0底层分析+bootloader</a><span>(10)</span>
</li>
</ul>
</div><div id="panel_Archive" class="panel">
<ul class="panel_head"><span>文章存档</span></ul>
<ul class="panel_body">
<div id="archive_list">
<!--归档统计-->
<li><a href="http://blog.csdn.net/liukun321/article/month/2013/07">2013年07月</a><span>(8)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2013/06">2013年06月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2013/05">2013年05月</a><span>(2)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2013/04">2013年04月</a><span>(5)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2013/02">2013年02月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2013/01">2013年01月</a><span>(4)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2012/06">2012年06月</a><span>(3)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2012/04">2012年04月</a><span>(2)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2012/03">2012年03月</a><span>(6)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2012/02">2012年02月</a><span>(11)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2012/01">2012年01月</a><span>(6)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2011/12">2011年12月</a><span>(8)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2011/11">2011年11月</a><span>(11)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2011/10">2011年10月</a><span>(20)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2011/09">2011年09月</a><span>(6)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2011/08">2011年08月</a><span>(4)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2011/07">2011年07月</a><span>(17)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2011/06">2011年06月</a><span>(14)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2011/05">2011年05月</a><span>(2)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2011/04">2011年04月</a><span>(2)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2011/02">2011年02月</a><span>(1)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2011/01">2011年01月</a><span>(4)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2010/10">2010年10月</a><span>(4)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2010/07">2010年07月</a><span>(2)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2010/06">2010年06月</a><span>(24)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2010/05">2010年05月</a><span>(74)</span></li><li><a href="http://blog.csdn.net/liukun321/article/month/2010/04">2010年04月</a><span>(2)</span></li>
</div>
</ul>
</div>
<div id="hotarticls" class="panel">
<ul class="panel_head"><span>阅读排行</span></ul>
<ul class="panel_body itemlist">
<li>
<a href="/liukun321/article/details/6662950" title="关于connect: network is unreachable 问题的解决">关于connect: network is unreachable 问题的解决</a><span>(18319)</span>
</li>
<li>
<a href="/liukun321/article/details/7438880" title="u-boot for tiny210 ver3.1 (by liukun321咕唧咕唧)">u-boot for tiny210 ver3.1 (by liukun321咕唧咕唧)</a><span>(7796)</span>
</li>
<li>
<a href="/liukun321/article/details/7270426" title="u-boot for tiny210 ver1.0(by liukun321咕唧咕唧)">u-boot for tiny210 ver1.0(by liukun321咕唧咕唧)</a><span>(6994)</span>
</li>
<li>
<a href="/liukun321/article/details/7046930" title="错误代码：0x800704cf 不能访问网络位置（win7 连不上smb了）">错误代码：0x800704cf 不能访问网络位置（win7 连不上smb了）</a><span>(5971)</span>
</li>
<li>
<a href="/liukun321/article/details/7422627" title="u-boot for tiny210 ver3.0 (by liukun321咕唧咕唧)">u-boot for tiny210 ver3.0 (by liukun321咕唧咕唧)</a><span>(4095)</span>
</li>
<li>
<a href="/liukun321/article/details/7383669" title="u-boot for tiny210 ver2.2.1(by liukun321咕唧咕唧)">u-boot for tiny210 ver2.2.1(by liukun321咕唧咕唧)</a><span>(3917)</span>
</li>
<li>
<a href="/liukun321/article/details/6645088" title="yaffs2 文件系统 内核启动时 Failed to execute /linuxrc.  问题的解决">yaffs2 文件系统 内核启动时 Failed to execute /linuxrc.  问题的解决</a><span>(3576)</span>
</li>
<li>
<a href="/liukun321/article/details/6658191" title="Uncompressing Linux..... done, booting the kernel.">Uncompressing Linux..... done, booting the kernel.</a><span>(3574)</span>
</li>
<li>
<a href="/liukun321/article/details/7315098" title="u-boot for tiny210 version2.0(by liukun321咕唧咕唧)">u-boot for tiny210 version2.0(by liukun321咕唧咕唧)</a><span>(3096)</span>
</li>
<li>
<a href="/liukun321/article/details/5636748" title="虽然是LPC但对UART FIFO的硬件原理说的比较清楚">虽然是LPC但对UART FIFO的硬件原理说的比较清楚</a><span>(3077)</span>
</li>
</ul>
</div>
<div id="hotarticls2" class="panel">
<ul class="panel_head"><span>评论排行</span></ul>
<ul class="panel_body itemlist">
<li>
<a href="/liukun321/article/details/7438880" title="u-boot for tiny210 ver3.1 (by liukun321咕唧咕唧)">u-boot for tiny210 ver3.1 (by liukun321咕唧咕唧)</a><span>(71)</span>
</li>
<li>
<a href="/liukun321/article/details/8558425" title="u-boot for tiny210 ver4.0 (by liukun321 咕唧咕唧)">u-boot for tiny210 ver4.0 (by liukun321 咕唧咕唧)</a><span>(33)</span>
</li>
<li>
<a href="/liukun321/article/details/7270426" title="u-boot for tiny210 ver1.0(by liukun321咕唧咕唧)">u-boot for tiny210 ver1.0(by liukun321咕唧咕唧)</a><span>(21)</span>
</li>
<li>
<a href="/liukun321/article/details/7383669" title="u-boot for tiny210 ver2.2.1(by liukun321咕唧咕唧)">u-boot for tiny210 ver2.2.1(by liukun321咕唧咕唧)</a><span>(10)</span>
</li>
<li>
<a href="/liukun321/article/details/8871963" title="基于Android2.3的车载导航---andorid GPS HAL的移植与分析（by liukun321咕唧咕唧）">基于Android2.3的车载导航---andorid GPS HAL的移植与分析（by liukun321咕唧咕唧）</a><span>(9)</span>
</li>
<li>
<a href="/liukun321/article/details/8491554" title="关于u-boot for tiny210 NFS启动Android根文件系统（by liukun321 咕唧咕唧）">关于u-boot for tiny210 NFS启动Android根文件系统（by liukun321 咕唧咕唧）</a><span>(8)</span>
</li>
<li>
<a href="/liukun321/article/details/7366309" title="u-boot for tiny210 ver2.2(by liukun321咕唧咕唧)">u-boot for tiny210 ver2.2(by liukun321咕唧咕唧)</a><span>(8)</span>
</li>
<li>
<a href="/liukun321/article/details/7422627" title="u-boot for tiny210 ver3.0 (by liukun321咕唧咕唧)">u-boot for tiny210 ver3.0 (by liukun321咕唧咕唧)</a><span>(7)</span>
</li>
<li>
<a href="/liukun321/article/details/5636748" title="虽然是LPC但对UART FIFO的硬件原理说的比较清楚">虽然是LPC但对UART FIFO的硬件原理说的比较清楚</a><span>(7)</span>
</li>
<li>
<a href="/liukun321/article/details/7046930" title="错误代码：0x800704cf 不能访问网络位置（win7 连不上smb了）">错误代码：0x800704cf 不能访问网络位置（win7 连不上smb了）</a><span>(6)</span>
</li>
</ul>
</div>
<div id="homepageArticles" class="panel">
<ul class="panel_head"><span>推荐文章</span></ul>
<ul class="panel_body" id="ad_commend"></ul>
</div>
<script type="text/javascript">
 new Ad(12, 'ad_commend');
</script><div id="newcomments" class="panel">
<ul class="panel_head"><span>最新评论</span></ul>
<ul class="panel_body itemlist">
    <li>
    <a href="/liukun321/article/details/9347191#comments">s5pv210 NV12 to RGB （fimc1实现硬解码数据在LCD显示）</a>
    <p style="margin:0px;"><a href="/liukun321" class="user_name">liukun321</a>:
@hooray113:可以通过 V4L2 以ioctl 方式调用到FIMC的驱动，或者移植andro...
    </p>
    </li>
    <li>
    <a href="/liukun321/article/details/9347191#comments">s5pv210 NV12 to RGB （fimc1实现硬解码数据在LCD显示）</a>
    <p style="margin:0px;"><a href="/hooray113" class="user_name">hooray113</a>:
请问一下，FIMC在linux下面要怎么使用？
    </p>
    </li>
    <li>
    <a href="/liukun321/article/details/8558425#comments">u-boot for tiny210 ver4.0 (by liukun321 咕唧咕唧)</a>
    <p style="margin:0px;"><a href="/disizu" class="user_name">disizu</a>:
你好，使一个ARM板子上烧写的uboot支持tftp 功能应该是怎样的移植过程 ？ 可能需要修改哪些...
    </p>
    </li>
    <li>
    <a href="/liukun321/article/details/7438880#comments">u-boot for tiny210 ver3.1 (by liukun321咕唧咕唧)</a>
    <p style="margin:0px;"><a href="/tangbin90" class="user_name">tangbin90</a>:
你好，在使用您的uboot从nandflash中启动，所有的命令丢失。板子是210v2 nandfl...
    </p>
    </li>
    <li>
    <a href="/liukun321/article/details/8871963#comments">基于Android2.3的车载导航---andorid GPS HAL的移植与分析（by liukun321咕唧咕唧）</a>
    <p style="margin:0px;"><a href="/liukun321" class="user_name">liukun321</a>:
@tbba321:hardware/libhardware/hardware.c里的hw_get_m...
    </p>
    </li>
    <li>
    <a href="/liukun321/article/details/8871963#comments">基于Android2.3的车载导航---andorid GPS HAL的移植与分析（by liukun321咕唧咕唧）</a>
    <p style="margin:0px;"><a href="/tbba321" class="user_name">tbba321</a>:
请问程序如何识别调用gps.default.so库的呢？我的tiny210用GPS_Test_Plu...
    </p>
    </li>
    <li>
    <a href="/liukun321/article/details/7438880#comments">u-boot for tiny210 ver3.1 (by liukun321咕唧咕唧)</a>
    <p style="margin:0px;"><a href="/kangear" class="user_name">kangear</a>:
启动方式的判断，挺好的，应用到了自己的代码中了。不像2440那样判断方法让人不舒服。
    </p>
    </li>
    <li>
    <a href="/liukun321/article/details/8558425#comments">u-boot for tiny210 ver4.0 (by liukun321 咕唧咕唧)</a>
    <p style="margin:0px;"><a href="/kumico" class="user_name">kumico</a>:
@weng1979:我用SD卡上的uboot启动成功，设置了IP等环境参数之后，只能ping通网关，...
    </p>
    </li>
    <li>
    <a href="/liukun321/article/details/7315098#comments">u-boot for tiny210 version2.0(by liukun321咕唧咕唧)</a>
    <p style="margin:0px;"><a href="/kumico" class="user_name">kumico</a>:
用SD卡上的uboot启动成功，设置了IP等环境参数之后，只能ping通网关，却ping不通网络上其...
    </p>
    </li>
    <li>
    <a href="/liukun321/article/details/7396596#comments">u-boot for tiny210 ver2.2.2(by liukun321咕唧咕唧)</a>
    <p style="margin:0px;"><a href="/DONGYU19910122" class="user_name">DONGYU19910122</a>:
samsung_get_base_clock 是在哪里定义的啊 一直找不到
    </p>
    </li>
</ul>
</div>
</div>
<div class="clear"></div>
</div>

<div class="clear"></div>
</div>

<script type="text/javascript" src="http://static.blog.csdn.net/scripts/newblog.min.js?v=1.1"></script>
<script type="text/javascript" src="http://medal.blog.csdn.net/showblogmedal.ashx?blogid=833043"></script>

<script type="text/javascript">
document.write('<script type="text/javascript" src="http://csdnimg.cn/pubfooter/js/publib_footer.js?' + Math.floor(new Date()/120000).toString(36) + '="></'+'script>');
</script>

<script type="text/javascript">document.write("<img src=http://counter.csdn.net/pv.aspx?id=24 border=0 width=0 height=0>");</script>
<script type="text/javascript" src="http://www.csdn.net/ui/scripts/Csdn/counter.js?v=1"></script>


<script type="text/javascript" src="http://ad.csdn.net/scripts/ad-blog.js"></script>

<script type="text/javascript" src="http://zz.csdn.net/js/count.js"></script>

</div>
</body>
</html>